/*
* @Author: gavin
* @Date:   2017-12-25 01:54:27
* @Last Modified by:   gavin
* @Last Modified time: 2017-12-25 01:58:49
*/
const fs = require('fs');
const path = require('path');
const dataDir = path.join(__dirname, 'data');
const mockDir = path.join(__dirname, 'mock');

const writeData = (cb) => {
	const mockfiles = fs.readdirSync(mockDir);
	mockfiles.forEach(function(file) {
		let dot = file.lastIndexOf(".");
		let fileName = file.substring(0,dot)+".json";
		let data = JSON.stringify(require(path.resolve(mockDir, file)));
		// console.log(data);
		fs.writeFile(path.resolve(dataDir, fileName), data ,err=>{if (err) throw err;});
	});
	cb();
};

writeData();
